﻿var _baseModel = {

     //did:window.location.href.split("?id=")[1],
     did:GetQueryString("did"),
     gatename: decodeURI(GetRequest("gatename")),
    userimage: "http://www.laoyou1.me/shhomer/output/GetImg.php?did="+GetQueryString("did")
}
function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
var _baseDataTime = {
    hours: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"],
    minute: ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59"]
}
function _scrollSame() { $('.divbox').scroll(function () { /**$('.divbox').scrollTop($(this).scrollTop());**/$('.divbox').scrollLeft($(this).scrollLeft()); }); }
//$(".headinfobox a").each(function () { this.href = this.href + "?id=" + _baseModel.did });

$(".jrjl").html(_baseModel.gatename);
$("#imgs").attr('src' , _baseModel.userimage);

var _baseformat = {
  formatTime: function (date) {
      if (date == null || date == undefined || date == 'null')  { return ''; }
      if(date == 'mei'){ return "???"}
    //   if(date == 'mei'){ return ""+"??"}
      if(date == 'loading'){ return '......'}
      if(date == '0'){ return '暂无数据'}
      if(date == '还在休息'){ return '还在休息'}

      date = date.replace(/-/g, "/")
      date = new Date(date);
      var hours = date.getHours();
      hours = hours < 10 ? "0" + hours : hours;
      var Minutes = date.getMinutes();
      Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
      return hours + ":" + Minutes;
  },
  formatstr: function (date) {
      if (date == null || date == undefined) { return; }
      if(date == 'mei'){ return '???'}
      if(date == 'loading'){ return '......'}
      date = date.replace(/-/g, "/")
      date = new Date(date);
      var hours = date.getHours();
      hours = hours < 10 ? "0" + hours : hours;
      var Minutes = date.getMinutes();
      Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
      return hours + ":" + Minutes;
  },
    formatDate: function (date) {
        if (date == null || date == undefined) { return; }
        date = date.replace(/-/g, "/")
        date = new Date(date);
        var _month = date.getMonth() + 1;
        _month = _month < 10 ? "0" + _month : _month;
        var _date = date.getDate();
        _date = _date < 10 ? "0" + _date : _date;
        return _month + "/" + _date + "/" + date.getFullYear();
    },
    formatDateTime: function (date) {
        if (date == null || date == undefined) { return; }
        date = date.replace(/-/g, "/")
        date = new Date(date);
        var _month = date.getMonth() + 1;
        _month = _month < 10 ? "0" + _month : _month;
        var _date = date.getDate();
        _date = _date < 10 ? "0" + _date : _date;
        var hours = date.getHours();
        hours = hours < 10 ? "0" + hours : hours;
        var Minutes = date.getMinutes();
        Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
        return date.getFullYear() + "/" + _month + "/" + _date + " " + hours + ":" + Minutes;
    },
    formatstring: function (date){
      if (date == null || date == undefined) { return; }
          date = new Date(date);
          var y = date.getFullYear();
          var m = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
          // Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
          var d  = date.getDate();
          d = d < 10 ? "0" + d : d;
          return y+"/"+m+"/"+d;
    }
}
function layerShow(id) {
    layer.open({
        type: 1,
        area: '95%',
        title: false,
        closeBtn: 0,
        skin: '',
        content: $("#" + id)
    });
}
function GetRequest(val) {
    var url = location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++) {
            theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1]);
        }
    }
    return val ? theRequest[val] : theRequest;
}
function GetDateStr(thisdate, AddDayCount) {
    var dd = (thisdate != null) ? dd = new Date(thisdate) : new Date();
    dd.setDate(dd.getDate() + AddDayCount);//获取AddDayCount天后的日期
    var y = dd.getFullYear();
    var m = dd.getMonth() + 1;//获取当前月份的日期
    var d = dd.getDate();
    return (y + "/" + m + "/" + d);
}
function getChartTime(thisdate) {
    var days = [];
    var dayscale = [];
    var datearray = [];
    for (var i = 7; i > 0; i--) { days.push(GetDateStr(thisdate, -i)); }
    datearray.starttime = days[0];
    datearray.endtime = days[days.length - 1];
    return { days: days, datearray: datearray };
}
